package tankgame06;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/12
 * @time 19:00
 */
public class TankGame06 extends JFrame {
    private MyPanel myPanel ;
    static Scanner scan = new Scanner(System.in);
    public TankGame06() throws HeadlessException {
        System.out.println("请输入选择：\n 1 新游戏 \n 2 继续上局");
        String key = scan.next();
        if (myPanel == null)
            myPanel = new MyPanel(key);
        Thread thread = new Thread(myPanel);
        thread.start();
        this.add(myPanel);
        this.setSize(1300,789);
        this.setVisible(true);
        this.addKeyListener(myPanel);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        new TankGame06();
    }
}
